<!DOCTYPE html>
<html>
<head>
    <title>用户中心 -- 快件e栈服务平台</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <link href="css/normalize.css" type="text/css" rel="stylesheet"/>
    <link href="css/common.css" type="text/css" rel="stylesheet"/>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/notice.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="layer/layer.js"></script>
    <style type="text/css">
        body {
            background: #f4f4f4;
        }

        .userInfoCont {

        }

        .userHeaderDiv {
            background: #fff;
        }

        .userHeaderDiv .userHeader {
            width: 90%;
            margin: 0 auto;
            overflow: hidden;
            padding: 20px 0px 10px;
            border-bottom: 1px solid #f1f1f1;
        }

        .userHeader .headerImg {
            width: 20%;
            float: left;
            border-radius: 50%;
            overflow: hidden;
        }

        .userHeader .headerImg img {
            display: block;
        }

        .userHeader p {
            margin: 0;
            margin-left: 15px;
            padding-left: 35px;
            font-weight: bold;
            float: left;
            background: url(images/student.png) no-repeat center left;
            background-size: 30px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .userHeaderDiv .headerProm {
            width: 90%;
            margin: 0 auto;
            font-size: 12px;
            color: #888888;
        }

        .headerProm .editUserInfo {
            line-height: 60px;
            font-size: 14px;
            color: #333333;
            background: url(images/rightArrow.png) no-repeat center right;
            background-size: 20px;
            border-bottom: 1px solid #f4f4f4;
        }

        .headerProm .expUserInfo {
            line-height: 60px;
            font-size: 14px;
            color: #333333;
            background: url(images/rightArrow.png) no-repeat center right;
            background-size: 20px;
        }

        .headerProm .userQRcode {
            line-height: 60px;
            font-size: 14px;
            color: #333333;
            background: url(images/rightArrow.png) no-repeat center right;
            background-size: 20px;
        }

        .userNewsCont {
            width: 90%;
            padding: 0px 5%;
            margin: 30px auto 10px;
            background: #fff;
        }

        .userNewsCont .userNews {
            width: 100%;
            border-bottom: 1px solid #f4f4f4;
            background: url(images/rightArrow.png) no-repeat center right;
            background-size: 20px;
        }

        .userNewsCont .userNews p {
            width: 80%;
            margin: 0px;
            padding-left: 30px;
            line-height: 60px;
            font-size: 12px;
            background: url(images/usernotice.png) no-repeat center left;
            background-size: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .userNewsCont .userNewsLast {
            border: none;
        }
    </style>
</head>
<body>
<script>
    $(function () {
        const infoDiv = $('.userHeaderDiv');
        function addInfo(str){
            $('.headerProm',infoDiv).prepend('<p>'+str+'</p>');
        }
        $.getJSON('/api/wx/userInfo', null, function (data) {
            if (data.status == -1) {
                setTimeout(() => window.location.href = "login.html", 2000);
            }
            if (data.status >= 0) {
                $('#name',infoDiv).html(data.data.nickname);
                $('#phone',infoDiv).html(data.data.phone);
                if (data.data.nickname !== '新用户'){
                    $('.toos').remove();
                    if (data.data.mail){
                        addInfo('邮箱：'+data.data.mail);
                    }
                    if (data.data.register_time){
                        addInfo('注册时间：'+data.data.register_time);
                    }
                }
                if (data.status == 0) $('.userHide').hide();
            }
        })
    })
</script>
<div class="content">
    <div class="headerNav">
        <div class="headerNavTop">
            <div class="headerNavIcon headerNavIconOut"><span></span><span></span></div>
        </div>
        <div class="headerNavCont">
            <a href="./index.html">快递首页</a>
            <a href="./userhome.html">个人中心</a>
            <a href="./delivery.html">送货上门</a>
            <!-- 	<a href="./sendexpress.html">我要寄件</a> -->
            <a href="./lazyboard.html">懒人排行</a>
            <a href="./expassistant.html">快递助手</a>
        </div>
    </div>

    <div class="userInfoCont">
        <div class="userHeaderDiv">
            <a href="wxIdCardUserInfoModify.html">
                <div class="userHeader">
                    <div class="headerImg">
                        <img src="images/userHeadImg.jpg" alt="正在加载中..." width="100%">
                    </div>
                    <p id="name">姓名</p>
                </div>
            </a>
            <div class="headerProm">
                <p>手机号：<span id="phone">12345678</span></p>
                <p class="toos">请及时完善个人信息，方便快递员配送</p>
                <input id="PageContext" type="hidden" value="${pageContext.request.contextPath}"/>
                <div class="toos editUserInfo">
                    完善个人信息
                </div>
                <div class="userQRcode">
                    我的取货二维码
                </div>
            </div>
        </div>

        <div class="userNewsCont">
            <div class="userNews toos userNewsRead">
                <p>[通知]请尽快完善个人信息，以便领取快递</p>
            </div>
        </div>
    </div>

    <div class="footer">
        <p class="copyInfotxt">&copy;新职课版权所有</p>
    </div>
</div>
<script>
    function bdate(a,b){
        if (a.length!==b.length) return a.length - b.length;
        for (let i=0;i<a.length;i++){
            if (a[i]!==b[i]){
                return Number(a[i]) -Number(b[i]);
            }
        }
        return 0;
    }
    const nuxs = $(' <div class="userNews  userNewsRead">\n' +
        '                <p>[<span id="time">2014-14-15</span>]<span id="reset">请尽快完善个人信息，以便领取快递</span></p>\n' +
        '            </div>');
    $.getJSON('/api/wx/findExpressList', null, function (data) {
        if (data.status < 0) {
            return;
        } else {
            let kuadiList = data.data;

            kuadiList.sort(function (a,b){
                a= (a.status === '未取出'?a.deposit_time:a.take_out_time);
                b= (b.status === '未取出'?b.deposit_time:b.take_out_time);
                return bdate(a,b);
            });
            kuadiList.forEach(val => {
                let p = nuxs.clone();
                if (val.status === '未取出'){
                    $('#time',p).html(val.deposit_time);
                    $('#reset',p).html("你有一个新的快递到了，取件码为："+val.pickup_code);
                }else {
                    $('#time',p).html(val.take_out_time);
                    $('#reset',p).html("你有一个快递被取出");
                }
                p.click(function (){
                    layer.msg($('#reset',this).html());
                })
                $('.userNewsCont').prepend(p);
            });
        }
    })
</script>
<script type="text/javascript">
    $(function () {
        var pageContextVal = $("#PageContext").val();
        var initFun = function () {
            var windowH = $(window).height();
            var contentH = $(".userInfoCont").height();
            if ((windowH - 30 - 50) > contentH) {
                $(".userInfoCont").css({"height": (windowH - 30 - 50) + "px"}); //nav footer
            }

            var headerW = $(".userHeader").width();
            var headImgH = headerW * 0.2;
            var headPW = headerW * 0.8 - 60; // 15+35
            $(".userHeader p").css({"line-height": headImgH + "px", "width": headPW + "px"});
        };

        initFun();

        $(window).resize(function () {
            initFun();
        });

        // user Info Edit
        $(".editUserInfo").click(function () {
            window.location.href = "userCheckStart.html";
        });
        $(".expUserInfo").click(function () {
            window.location.href = "userLazyboard.html";
        });
        $(".userQRcode").click(function () {
            window.location.href = "/api/wx/createQRCode?type=user";
        });
    });
</script>
</body>
</html>